<%@ page language="java" pageEncoding="UTF-8"%>  
  <% String appName = request.getContextPath(); %>
 
<link rel="stylesheet" type="text/css" href="<%=appName %>/js/themes/metro-orange/easyui.css">
<script type="text/javascript" src="<%=appName %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=appName %>/js/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="<%=appName %>/js/themes/icon.css">
<body>
 <div style="width:400px;height:400px;margin:400px auto;"> 
<div style="color:red; font-size:22px;">${message_login}</div>  
  <div style="margin-bottom:20px">
                <input id="oldPasswd" class="easyui-textbox" name="name"  type="password" style="width:100%" data-options="label:'原密码：:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input id = "newpasswd" class="easyui-textbox" name="email"  type="password"style="width:100%" data-options="label:'新密码:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input id = "confirm" class="easyui-textbox" name="subject" type="password" style="width:100%" data-options="label:'确认新密码:',required:true">
   </div>
<div>
            <a href="#" class="easyui-linkbutton" iconCls="icon-ok" style="width:100%;height:32px" onclick="doit()">确认</a>
        </div>
    </div>
    <script>
    function doit(){
    	var newpasswd = $('#newpasswd').textbox('getText');
    	var oldPasswd = $('#oldPasswd').textbox('getText');
    	var confirm = $('#confirm').textbox('getText');
    	if(newpasswd != confirm){
            $.messager.alert('错误',"密码输入不一致",'error');
            return ;
        }
    	$.ajax({
            url: "<%=appName%>/mvc/security/chgpasswd",
            type: "POST",
            dataType: "json",
            data: {
            	oldPasswd: oldPasswd,
                newPasswd: newpasswd,
            },
            success: function(data){
                if(data.code=="0"){
                    $.messager.alert('消息',"操作成功：密码已修改" ,'info');
                } else {
                    $.messager.alert('错误',data.message,'error');
                }
            },
            error: function(xml){
                $.messager.alert('错误',"连接服务器失败！",'error');
            }
        });
    }
    </script>
</body>    
